package org.whuims.web.api;

import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.whuims.entity.News;
import org.whuims.service.account.ShiroDbRealm;
import org.whuims.service.news.NewsService;

/**
 * Created by Qikai on 2016/11/7.
 */
@Controller
@RequestMapping(value = "/image")
public class FileController {
    @Autowired
    private NewsService newsService;

    @RequestMapping(value = "create", method = RequestMethod.GET)
    public String createForm(Model model) {
        News news = new News();
        model.addAttribute("task", news);
        model.addAttribute("action", "create");
        return "news/newsedit";
    }


    /**
     * 取出Shiro中的当前用户Id.
     */
    private Long getCurrentUserId() {
        ShiroDbRealm.ShiroUser user = (ShiroDbRealm.ShiroUser) SecurityUtils.getSubject().getPrincipal();
        return user.id;
    }
}
